package com.parse.ip.parseip.producer;

import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;

import javax.jms.Destination;

/**
 * 生产者 producer
 *
 * */


@Component
public class Producer {
    @Autowired
    private JmsTemplate jmsTemplate;

    public void sendMessage(String message){
        System.out.println("生产者发送消息-->"+message);
        Destination destination = new ActiveMQQueue("producer ququ");
        jmsTemplate.convertAndSend(destination,message);
    }

    /**
     *
     * @param destination 消息队列名
     * @param message
     */
    public void topicMessage(Destination destination,String message){
        System.out.println("广播模式-->"+message);
        jmsTemplate.convertAndSend(destination,message);
    }
}
